<template>
  <div class="box">
    <div class="box-22">
      <div>账号：666</div>
      <div>密码：666</div>
    </div>
    <img src="../image/66.jpg" alt="" style="width: 100%;height: 1000px">
    <div class="titlie">谢氏物资信息管理系统 <br>XIESHIWUZHIGUANLIXITONG</div>
    <div class="login">
      <el-card style="width: 350px;margin-left: 100px;margin-top: 80px;background: none;border: none;color: white">
        <div slot="header" style="text-align: center;font-size: 20px;margin-top: 40px"><h3>登录</h3></div>
        <el-form inline :model="user" :rules="loginrules" ref="ruleForm" >
          <el-form-item class="car" prop="account">
            <div style="font-size: 20px">账号:</div>
            <div  class="pass-box" style="margin-left: 10px">
              <el-input
                  placeholder="  请输入账号"
                  v-model="user.account"
                  clearable
                  class="el-input__inner"
              >
              </el-input>
            </div>

          </el-form-item>


          <el-form-item class="car" prop="password">
            <div style="font-size: 20px">密码:</div>
            <div class="pass-box" style="margin-left: 10px">
              <el-input
                  placeholder="  请输入密码"
                  v-model="user.password"
                  show-password
                  class="el-input__inner"
              >
              </el-input>
            </div>

          </el-form-item>

          <div style="margin-left: 5px;">
            <el-button style="width: 300px;background-color: springgreen;color: white" @click="login">登录</el-button>

          </div>

          <div style="margin-left: 5px;margin-top: 15px">
            <el-button style="width: 300px;background:none"  @click="empty">重置</el-button>

          </div>
<!--          <div style="margin-left: 5px;margin-top: 15px">-->
<!--            <el-button style="width: 300px" type="primary" @click="$router.push('reqister')">注册</el-button>-->
<!--          </div>-->
        </el-form>
      </el-card>


    </div>
  </div>


</template>

<script>

export default {
  name: "login",
  data() {
    return {
      user: {
        account:'',
        password:'',
      },

      loginrules: {
        account: [
          {required: true, message: '请输入账号', trigger: 'blur'},
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'change'},
          {min: 3, max: 9, message: '长度在 3 到 5 个字符', trigger: 'blur'}
        ],
      }
    }

  },
  methods: {

    login() {

        this.$refs.ruleForm.validate((r) => {
          if (r) {
            this.$axios.post("/api/user/login", this.user).then(res => {
              console.log(res);

              if (res.data.status === 1) {
                localStorage.setItem("TOKEN", res.data.data.token);
                this.$message.success(res.data.msg);
                this.$router.push('index');
              }else {
                this.$message.error(res.data.msg);
              }
            });
          } else {
              this.$message.error("请填写资料");
          }
        });



    },
    empty(){
      this.user.account="";
      this.user.password="";

    }

  }
}
</script>

<style>
.box {
  position: relative;
  height: 900px;
}
.box-22{
  width: 150px;
  height: 100px;
  background-color: white;
color: darkgoldenrod;
  position: absolute;
  top: 100px;
  left: 100px;
}
.box-22 div{
  line-height: 50px;
  margin-left: 20px;
}

.login {
  position: absolute;
  top: 200px;
  right: 650px;
  width: 60px;
  height: 100px;

}
.titlie{
  position: absolute;
  top: 740px;
  text-align: center;
  left: 300px;
  font-size: 70px;
  color: white;
}
.car div {
  display: inline-block;
}
.el-input__inner{
background-color: #FFFFFF00 !important;
 background: none;
  padding: 0;
color: white;

}
</style>